home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / varia / egebook.lha / ege.book / 5 / Schedule.C < prev    next >
C/C++ Source or Header  |  1992-06-07  |  1KB  |  55 lines

  1. #include <iostream.h>
  2. #include <bool.h>
  3.  
  4. #include "Schedule.h"
  5. #include "Example.h"
  6. #include "Collection.h"
  7. #include "Course.h"
  8. #include "Professor.h"
  9. #include "TeachingAssistant.h"
  10. #include "ScheduledCourse.h"
  11.  
  12. Collection* Schedule::All = new Collection;
  13.  
  14. void Schedule::maintain(){
  15.   String selection;
  16.  
  17.   while (TRUE) {
  18.     cout << "assign (a) new course or maintain (m) ? ";
  19.     cin >> selection;
  20.     if (selection.contains("a"))
  21.       assign();
  22.     else if (selection.contains("m")) {
  23.       cout << "these courses are offered:\n";
  24.       offerings->maintain();
  25.     } else
  26.       break;
  27.   };
  28. }
  29.  
  30. void Schedule::assign() {
  31.   Example *selection;
  32.   ScheduledCourse *schedCourse;
  33.  
  34.   cout << "select a course:\n";
  35.   if ((selection = Course::All->select()) != NULL) {
  36.     schedCourse = new ScheduledCourse(selection);
  37.     cout << "enter time: ";
  38.     cin >> schedCourse->time;
  39.     cout << "select a teacher:\n";
  40.     if ((selection=Professor::All->select()) != NULL) {
  41.       schedCourse->teacher = selection;
  42.       cout << "select first teaching assistant:\n";
  43.       if ((selection=TeachingAssistant::All->select()) != NULL) {
  44.         schedCourse->assistants[0] = selection;
  45.         cout << "select second teaching assistant:\n";
  46.         if ((selection=TeachingAssistant::All->select()) != NULL) {
  47.           schedCourse->assistants[1] = selection;
  48.           if (schedCourse->check())
  49.             offerings->add(schedCourse);
  50.         };
  51.       };
  52.     };
  53.   };
  54. }
  55.